package com.bytedance.improvingroad.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bytedance.improvingroad.R
import com.bytedance.improvingroad.utils.Utils

/**
 * Created by chenxiong
 * date 1/23/22
 */
class RvSingleTextAdapter : RecyclerView.Adapter<RvSingleTextAdapter.TextViewHolder>() {

    private val dataList = Utils.getMutableData()

    class TextViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        private val tv_view: TextView = itemView.findViewById(R.id.rv_text_view)

        fun bind(content: String) {
            tv_view.text = content
        }
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TextViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.rv_single_text_layout,parent, false)
        return TextViewHolder(view)
    }

    override fun onBindViewHolder(holder: TextViewHolder, position: Int) {
        holder.bind(dataList[position])
    }

    override fun getItemCount() = dataList.size
}